import React from 'react';
import { GameRulesTypeA } from '@/services/game/GameController';
import { ProForm, ProFormCheckbox, ProFormText } from '@ant-design/pro-components';


/**
 * 积分晋级赛详细规则
 */
interface Props {
  name?: string
  data?: GameRulesTypeA
}
const GameRulesFormTypeAView = ({ name, data }: Props) => {

  return (
    <>
      <ProForm.Group label='基础规则'>
        <ProFormText
          width="sm"
          initialValue={data?.basicPoints ?? 20}
          name={[name, 'basicPoints']}
          label="基础分"
          rules={[
            {
              pattern: /^[0-9]+$/,
              required: true,
              message: '请输入基础分',
            },
          ]}
        />
        <ProFormText
          width="sm"
          initialValue={data?.promotePoints ?? 100}
          name={[name, 'promotePoints']}
          label="晋级分"
          rules={[
            {
              pattern: /^[0-9]+$/,
              required: true,
              message: '请输入晋级分',
            },
          ]}
        />
      </ProForm.Group>
      <ProForm.Group label='排名规则' style={{ marginTop: 5 }}>
        <ProFormCheckbox.Group
          name={[name, 'rankingCheck']}
          initialValue={data?.rankingCheck ?? [1, 2, 3]}
          options={[
            {
              label: '比赛积分',
              value: 1,
            },
            {
              label: '比赛用时',
              value: 2,
            },
            {
              label: '净胜场',
              value: 3,
            },
          ]}
        />
      </ProForm.Group>

      <ProForm.Group label='积分规则 [得分=max(负方分*得分比例,10) 四舍五入取整10，胜方加得分值，负方扣得分值]' style={{ marginTop: 5 }} >
        <ProFormText
          width="sm"
          name={[name, 'pointsRatio']}
          initialValue={data?.pointsRatio ?? 50}
          label="得分比例(%)"
          rules={[
            {
              pattern: /^[0-9]+$/,
              required: true,
              message: '请输入得分比例',
            },
          ]}
        />
      </ProForm.Group>
      <ProForm.Group label='弃权规则' style={{ marginTop: 5 }}>
        <ProFormText
          width="sm"
          name={[name, 'abstainTime']}
          initialValue={data?.abstainTime ?? 50}
          label="胜方比赛用时(分)"
          rules={[
            {
              pattern: /^[0-9]+$/,
              required: true,
              message: '请输入胜方比赛用时(分)',
            },
          ]}
        />

      </ProForm.Group>
      <ProForm.Group label='淘汰规则' style={{ marginTop: 5 }}>
        <ProFormText
          width="sm"
          name={[name, 'outPoints']}
          initialValue={data?.outPoints ?? 0}
          label="积分"
          rules={[
            {
              pattern: /^[0-9]+$/,
              required: true,
              message: '请输入积分',
            },
          ]}
        />
      </ProForm.Group>
    </>
  );
};

export default GameRulesFormTypeAView;
